package com.sailfish.template.infra.feign;


import com.sailfish.template.infra.common.constants.ResponseEntity;
import com.sailfish.template.infra.feign.callback.SailfishIamClientFallback;
import com.sailfish.template.infra.feign.dto.OrganizationDTO;
import com.sailfish.template.infra.feign.dto.ProjectDTO;
import com.sailfish.template.infra.feign.dto.UserDTO;
import com.sailfish.template.infra.feign.vo.IamProjectVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author XIAXINYU3
 * @date 2021/11/2
 */
@FeignClient(value = "sailfish-iam", fallback = SailfishIamClientFallback.class)
public interface SailfishIamClient {

    @PostMapping("/v1/projects/add_project/within")
    ResponseEntity<IamProjectVO> createProjectWithin(@RequestParam(name = "organization_id") Long organizationId,
                                                     @RequestBody @Validated IamProjectVO iamProject);

    @GetMapping(value = "/v1/projects/{projectId}")
    ResponseEntity<ProjectDTO> queryIamProject(@PathVariable("projectId") Long projectId);


    @GetMapping("/v1/organizations/{organizationId}")
    ResponseEntity<OrganizationDTO> queryOrganizationById(@PathVariable("organizationId") Long organizationId);


    @PostMapping(value = "/v1/users/ids")
    ResponseEntity<List<UserDTO>> listUsersByIds(@RequestBody Long[] ids);


    @GetMapping(value = "/v1/projects/{project_id}/list/users")
    ResponseEntity<List<UserDTO>> list(@PathVariable(name = "project_id") Long id,
                                       @RequestParam(required = false, name = "id") Long userId,
                                       @RequestParam(required = false, name = "param") String param);
}
